import csv
from datetime import datetime
import matplotlib.pyplot as plt

filename = 'data/sitka_weather_2018_simple.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)

#收集降雨量数据
    preps,dates =[],[]
    for row in reader:
        date = datetime.strptime(row[2],'%Y-%m-%d')
        try:
            prep = float(row[3])
        except ValueError:
            print(f"Missing data for {date}")
        else:
            preps.append(prep)
            dates.append(date)

#可视化
plt.style.use('seaborn')
fig,ax = plt.subplots(dpi=128)
ax.plot(dates,preps,c='blue')

ax.set_title('PRCP',fontsize=24)
ax.set_xlabel("",fontsize=14)
ax.set_ylabel("prcp",fontsize=14)

plt.show()